package com.molin.variableParameterTest;

import java.util.*;

public class Demo2 {
    //List,Set,Map 创建不可变集合
    public static void main(String[] args) {
        List<String> stringList=List.of("a","b","c","d");
        System.out.println(stringList);
//        stringList.add("ab");
        ArrayList<String> list1=new ArrayList<>(List.of("a","b","c","d"));
        //传递的参数中不能存在重复的元素。
        Set<String> set1=new TreeSet<>(Set.of("a","b","c","d"));
        Map<String,Integer> map1=new HashMap<String,Integer>(Map.of("zs",23,"wangwu",25));
        Map<String,Integer> map2=new HashMap<String,Integer>(Map.ofEntries(
                Map.entry("zhangsan",23),
                Map.entry("lisi",25),
                Map.entry("lwangwu",26)
        ));
        System.out.println(map2);

    }
}